﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DB_test
{
    class Jump
    {
        public int Id { get; set; }
        private float Height;
        private JumpTypes Type;
        public int DiverId { get; set; }

        public Jump() { }

        public Jump(float height, JumpTypes type, int diverId)
        {
            this.Height = height;
            this.Type = type;
            this.DiverId = diverId;
        }

        public Jump(float height, JumpTypes type)
        {
            this.Height = height;
            this.Type = type;
        }

        public static Jump GetFromDictionary(Dictionary<String, Object> data)
        {
            return new Jump
            {
                Id = (int)data["Id"],
                Height = (float)(Double)data["Height"],
                Type = (JumpTypes)data["Type"],
                DiverId = (int)data["DiverId"]
            };
        }

        public Dictionary<String, Object> GetDictionary()
        {
            var dictionary = new Dictionary<String, Object>();
            dictionary.Add("Id", this.Id.ToString());
            dictionary.Add("Height", this.Height.ToString().Replace(",", "."));
            dictionary.Add("Type", ((int)this.Type).ToString());
            dictionary.Add("DiverId", this.DiverId.ToString());
            return dictionary;
        }

        public String ToString()
        {
            return String.Format("Height:{0}, Type:{1}", this.Height, this.Type.ToString());
        }


        public static string GetIdField()
        {
            return "Id";
        }
    }
    public enum JumpTypes
    {
        Hard,
        Easy

    }
}
